import Joi from '@hapi/joi';

export const destroyRule = {
  params: {
    id: Joi.number()
  },
};

export const list = {
  query: {
    page: Joi.number()
      .integer()
      .min(1)
      .default(1),
    pageSize: Joi.number()
      .integer()
      .min(10)
      .max(100)
      .default(10),
    type: Joi.number().allow(''),
    username: Joi.string().trim().allow(''),
    email: Joi.string().trim().allow(''),
  },
};

export const createRule = {
  body: {
    username: Joi.string()
      .trim()
      .required(),
    mobile: Joi.string()
      .trim()
      .allow(''),
    email: Joi.string()
      .allow(''),
    password: Joi.string()
      .trim()
      .required()
      .description('密码'),
    type: Joi.number()
      .required()
      .description('类型'),
  },
};

export const updateRule = {
  params: {
    id: Joi.string()
      .trim()
      .required(),
  },
  body: {
    username: Joi.string()
      .trim()
      .required(),
    mobile: Joi.string()
      .trim()
      .allow(''),
    email: Joi.string()
      .allow(''),
    type: Joi.number()
      .required()
      .description('类型'),
  },
};
